/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package game;

import framework.GameObject;
import framework.Screen;
import framework.Util;
import framework.gameAPI.Sprite;
import java.awt.Graphics;
import java.util.Calendar;

/**
 *
 * @author Ilha - 01
 */
public class Bomb extends GameObject {

    private static final int[] ANIM_BOMB_IDLE = {0, 2, 4, 4, 2};
    private static final int[] ANIM_BOMB_EXPLODE = {1, 3, 5};
    private boolean visible;
    private boolean explosion;
    private Long duration;
    private Long startTime;
    private Sprite sprite;
    private int explosionSize;


    public Bomb(int x, int y, int speedX, int speedY) {
        this.x = x;
        this.y = y;
        this.speedX = speedX;
        this.speedY = speedY;
        this.sprite = new Sprite(Util.loadImage(Global.IMG_BOMB), 32, 32);
        width = sprite.getWidth();
        height = sprite.getHeight();

        this.sprite.setFrameSequence(ANIM_BOMB_IDLE);

        visible = true;
        duration = 5000000l;
        startTime = System.nanoTime();
        explosionSize = 3;
    }

    @Override
    public void update() {
        Long nowTime = System.nanoTime();
        if(nowTime - startTime >= duration){
            explosion = true;
        }
        

        if(explosion){
            this.sprite.setFrameSequence(ANIM_BOMB_EXPLODE);
            this.sprite.setHeight(height*2);
            

        }


    }

    @Override
    public void paint(Graphics g) {
        if (visible) {
            this.sprite.setX(x);
            this.sprite.setY(y);
            sprite.paint(g);
        }

    }
}
